package com.supergzt.config;

import com.supergzt.interceptor.HeaderInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author 张钧
 * @Description
 * @create 2022-09-25 10:03
 */
@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

	@Resource
	private HeaderInterceptor headerInterceptor;

	/**
	 * 不需要拦截地址
	 */
	public static final String[] EXCLUDE_URLS = {"/login", "/logout"};

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(headerInterceptor)
				.addPathPatterns("/**")
				.excludePathPatterns(EXCLUDE_URLS)
				.order(-10);
	}
}

